package cn.dengta.webapp.user.entity;

import java.util.Date;

import cn.dengta.common.model.ValueProxy;
import cn.dengta.context.model.LabelI18nProxy;
import cn.dengta.webapp.base.entity.BizEntity;
import cn.dengta.webapp.user.model.Gender;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
import me.codeplayer.util.StringUtil;

/**
 * 用户注销日志
 *
 * @author lgy
 * @since 2022-04-14
 */
@Setter
@Getter
@Accessors(chain = true)
public class UserDestroyLog extends BizEntity {

	/** 用户Id */
	private Long userId;
	/** 昵称 */
	protected String nickname;
	/** 操作用户Id */
	private Long addUserId;
	/** IP地址 */
	private String addIp;
	/** 备注信息 */
	private String remark;
	/** 注销时间 */
	private Date destroyTime;

	public UserDestroyLog init(Long userId, Long addUserId, String addIp, String remark, Date now) {
		this.userId = userId;
		this.addUserId = addUserId;
		this.addIp = addIp;
		this.remark = StringUtil.toString(remark);
		super.initTime(now);
		return this;
	}

	public void setId(Long id) {
		this.id = id;
	}

	@Getter
	public enum DestroyStatus implements LabelI18nProxy<DestroyStatus, Integer> {
		/** 已过期 */
		EXPIRE(9, "已过期"),
		/** 已注销 */
		DESTROY(1, "已注销"),
		/** 注销中 */
		DESTROY_ING(0, "注销中")
		;

		public final Integer value;
		public final ValueProxy<DestroyStatus, Integer> proxy;

		DestroyStatus(Integer value, String label) {
			this.value = value;
			this.proxy = new ValueProxy<>(this, value, label);
		}

		public static DestroyStatus[] getValues() {
			return ValueProxy.getCachedArray(DestroyStatus.class, DestroyStatus::values);
		}

		public static DestroyStatus of(Integer value) {
			return EXPIRE.getValueOf(value);
		}
	}

}
